﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace TowerDefence
{
    [System.Serializable]
    public class PlayerData
    {
        public bool tutorialFinished;  // 教程是否完成的标志

        public int money;  // 玩家拥有的金钱数量
        public int gem;  // 玩家拥有的宝石数量

        public int enemyLogIndex;  // 敌人日志的索引

        public int goldItemAmount;  // 金币道具的数量
        public int healthItemAmount;  // 生命道具的数量
        public int bombItemAmount;  // 炸弹道具的数量
        public int freezeTimeItemAmount;  // 冻结时间道具的数量

        [Header("Level Scores")]
        public static List<int> starScoresPerLevel = new List<int>();  // 每个关卡的星级得分列表
        public int levelsUnlocked = 1;  // 已解锁的关卡数

        public int arrowTowerIndex01;  // 箭塔01的索引
        public int arrowTowerIndex02;  // 箭塔02的索引
        public int arrowTowerIndex03;  // 箭塔03的索引
        public int fireTowerIndex01;  // 火塔01的索引
        public int fireTowerIndex02;  // 火塔02的索引
        public int fireTowerIndex03;  // 火塔03的索引
        public int cannonTowerIndex01;  // 加农炮塔01的索引
        public int cannonTowerIndex02;  // 加农炮塔02的索引
        public int cannonTowerIndex03;  // 加农炮塔03的索引
        public int poisonTowerIndex01;  // 毒塔01的索引
        public int poisonTowerIndex02;  // 毒塔02的索引
        public int poisonTowerIndex03;  // 毒塔03的索引

        public List<int> crossbowUpgradeShopButtonIndexes = new List<int>(3);  // 弩升级商店按钮的索引列表
        public List<int> fireUpgradeShopButtonIndexes = new List<int>(3);  // 火塔升级商店按钮的索引列表
        public List<int> cannonUpgradeShopButtonIndexes = new List<int>(3);  // 加农炮塔升级商店按钮的索引列表
        public List<int> poisonUpgradeShopButtonIndexes = new List<int>(3);  // 毒塔升级商店按钮的索引列表

        public List<int> levelStars = new List<int>();  // 每个关卡的星级列表
        [Range(0, 1)]
        public float soundValue;  // 音效音量
        [Range(0, 1)]
        public float musicValue;  // 音乐音量

        public PlayerData(PlayerDataManager playerDataManager)
        {
            tutorialFinished = PlayerDataManager.TutorialFinished;  // 教程是否完成的标志

            money = PlayerDataManager.Money;  // 玩家金钱数量
            gem = PlayerDataManager.Gem;  // 玩家宝石数量

            soundValue = PlayerDataManager.SoundValue;  // 音效音量
            musicValue = PlayerDataManager.MusicValue;  // 音乐音量

            enemyLogIndex = PlayerDataManager.EnemyLogIndex;  // 敌人日志索引

            goldItemAmount = PlayerDataManager.GoldItemAmount;  // 金币道具数量
            healthItemAmount = PlayerDataManager.HealthItemAmount;  // 生命道具数量
            bombItemAmount = PlayerDataManager.BombItemAmount;  // 炸弹道具数量
            freezeTimeItemAmount = PlayerDataManager.FreezeTimeItemAmount;  // 冻结时间道具数量

            levelsUnlocked = PlayerDataManager._levelsUnlocked;  // 已解锁的关卡数

            // 复制每个关卡的星级得分
            for (int i = 0; i < PlayerDataManager.starScoresPerLevel.Count; i++)
            {
                levelStars.Add(PlayerDataManager.starScoresPerLevel[i]);
            }

            // 复制各种塔的索引
            arrowTowerIndex01 = PlayerDataManager.arrowTowerIndex01;
            arrowTowerIndex02 = PlayerDataManager.arrowTowerIndex02;
            arrowTowerIndex03 = PlayerDataManager.arrowTowerIndex03;
            fireTowerIndex01 = PlayerDataManager.fireTowerIndex01;
            fireTowerIndex02 = PlayerDataManager.fireTowerIndex02;
            fireTowerIndex03 = PlayerDataManager.fireTowerIndex03;
            cannonTowerIndex01 = PlayerDataManager.cannonTowerIndex01;
            cannonTowerIndex02 = PlayerDataManager.cannonTowerIndex02;
            cannonTowerIndex03 = PlayerDataManager.cannonTowerIndex03;
            poisonTowerIndex01 = PlayerDataManager.poisonTowerIndex01;
            poisonTowerIndex02 = PlayerDataManager.poisonTowerIndex02;
            poisonTowerIndex03 = PlayerDataManager.poisonTowerIndex03;
        }

    }
}

